package com.xudow.app.dynamicstate_old.module.discovery.search;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.ViewGroup;

import com.jude.beam.bijection.RequiresPresenter;
import com.jude.beam.expansion.list.BeamListFragment;
import com.jude.beam.expansion.list.ListConfig;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.jude.easyrecyclerview.decoration.DividerDecoration;
import com.jude.utils.JUtils;
import com.xudow.app.R;
import com.xudow.app.dynamicstate_old.domain.entity.UserInfoVo;
import com.xudow.app.dynamicstate_old.module.discovery.viewholder.UserSearchViewHolder;

/**
 * Created by zhuchenxi on 16/6/24.
 */

@RequiresPresenter(UserSearchPresenter.class)
public class UserSearchFragment extends BeamListFragment<UserSearchPresenter,UserInfoVo> {


    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        getListView().addItemDecoration(new DividerDecoration(getResources().getColor(R.color.gray100), JUtils.dip2px(1)));
    }

    public void search(String text){
        getPresenter().word = text;
        getPresenter().getAdapter().clear();
        getListView().showProgress();
        getPresenter().onRefresh();
    }

    @Override
    public ListConfig getConfig() {
        return super.getConfig().setRefreshAble(false)
                .setStartWithProgress(false);
    }

    @Override
    public BaseViewHolder<UserInfoVo> getViewHolder(ViewGroup parent, int viewType) {
        return new UserSearchViewHolder(parent);
    }
}
